Python: fix(google-ai): skip api_key check when use_vertexai is True#13607
Python: fix(google-ai): skip api_key check when use_vertexai is True#13607giulio-leone wants to merge 2 commits intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
27f8e4d to
ce250e0
Compare
|
Friendly ping — CI is green and this is ready for review. Happy to address any feedback. Thanks! |
ce250e0 to
3814db8
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Google AI connector initialization for Vertex AI usage by skipping the api_key requirement when use_vertexai=True, aligning the validation logic with the intended ADC authentication path.
Changes:
- Guard
api_keyvalidation withnot use_vertexaiinGoogleAIChatCompletion. - Guard
api_keyvalidation withnot use_vertexaiinGoogleAITextCompletion. - Guard
api_keyvalidation withnot use_vertexaiinGoogleAITextEmbedding.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py | Skip API key validation when using Vertex AI during initialization. |
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py | Skip API key validation when using Vertex AI during initialization. |
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py | Skip API key validation when using Vertex AI during initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py
Show resolved
Hide resolved
|
Hi! Gentle ping — this PR is rebased, CI passes, and ready for review. Happy to address any feedback. Thanks! |
d8cb434 to
56c3e4c
Compare
|
Friendly ping — CI is green, tests pass, ready for review whenever convenient. Happy to address any feedback. Thanks! 🙏 |
56c3e4c to
2bf8b08
Compare
|
Hi — all 4 threads resolved. cloud_region validation added to all 3 service classes. Fixes #13483. Ready for review! |
Head branch was pushed to by a user without write access
77e740d to
a6aa391
Compare
|
Rebased this branch onto current Local validation (Pass 1 and Pass 2)
Direct runtime proof (real source files, not mocks)Using the real
Results were identical across both proof passes:
So the rebased PR still fixes the original bug on all 3 Google AI service initializers while preserving the new |
a6aa391 to
083fafc
Compare
|
Just need the CI/CD checks to pass and we'll get this merged. We will monitor. |
083fafc to
8ba149c
Compare
|
Rebased this branch onto the current Local validation (Pass 1 and Pass 2)
Direct runtime proof against current
|
| Case | Chat | Text | Embedding |
|---|---|---|---|
current main + use_vertexai=True + no api_key |
ServiceInitializationError: The API key is required when use_vertexai is False. |
same | same |
rebased PR branch + use_vertexai=True + no api_key |
initializes successfully | initializes successfully | initializes successfully |
rebased PR branch + use_vertexai=True + missing cloud_region |
ServiceInitializationError: Region must be provided when use_vertexai is True. |
same | same |
So after rebasing onto the latest main, this PR still fixes the original Vertex AI initialization bug on all three Google AI service initializers while preserving the fast-fail cloud_region validation path.
|
Small status note on the refreshed head If that is just the usual maintainer approval step for fork workflows, that looks like the remaining blocker on the new head. If not, I am happy to investigate further from my side. |
Summary
Fixes #13483
Motivation and Context
When
use_vertexai=True, users authenticate via Application Default Credentials (ADC) and don't need an API key. However, the initialization check forapi_keyruns unconditionally, blocking Vertex AI users with:Description
Guard the
api_keyvalidation withnot google_ai_settings.use_vertexaiin all three Google AI service classes:GoogleAIChatCompletionGoogleAITextCompletionGoogleAITextEmbeddingThe error message already reads "when use_vertexai is False", so the condition now matches the intent.
Before / After
Contribution Checklist